<?php

/**
 * This is the model class for table "{{stage}}".
 *
 * The followings are the available columns in table '{{stage}}':
 * @property integer $id
 * @property string $debut_de_stage
 * @property string $fin_de_stage
 * @property integer $duree_de_stage
 * @property string $mission
 * @property string $enterprise_nom
 * @property string $enterprise_groupe
 * @property string $enterprise_rue1
 * @property string $enterprise_rue2
 * @property string $enterprise_ville
 * @property string $enterprise_cp
 * @property string $enterprise_pays
 * @property string $enterprise_tel
 * @property string $enterprise_rh_prenom
 * @property string $enterprise_rh_nom
 * @property string $enterprise_rh_contact
 * @property string $enterprise_lieu_groupe
 * @property string $enterprise_lieu_rue1
 * @property string $enterprise_lieu_rue2
 * @property string $enterprise_lieu_ville
 * @property string $enterprise_lieu_cp
 * @property string $enterprise_lieu_pays
 * @property string $enterprise_lieu_tel
 * @property integer $rapportEvaluation_id
 * @property integer $professeur_id
 * @property integer $tuteurEvaluation_id
 * @property integer $enterprise_id
 * @property integer $soutenanceEvaluation_id
 * @property integer $etudiant_id
 * @property integer $stageContext_id
 *
 * The followings are the available model relations:
 * @property Etudiant $etudiant
 * @property StageContext $stageContext
 * @property Enterprise $enterprise
 * @property Professeur $professeur
 * @property RapportEvaluation $rapportEvaluation
 * @property SoutenanceEvaluation $soutenanceEvaluation
 * @property TuteurEvaluation $tuteurEvaluation
 */
class Stage extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Stage the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{stage}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('rapportEvaluation_id, professeur_id, tuteurEvaluation_id, enterprise_id, soutenanceEvaluation_id, etudiant_id, stageContext_id', 'required'),
			array('duree_de_stage, rapportEvaluation_id, professeur_id, tuteurEvaluation_id, enterprise_id, soutenanceEvaluation_id, etudiant_id, stageContext_id', 'numerical', 'integerOnly'=>true),
			array('enterprise_nom, enterprise_groupe, enterprise_rue1, enterprise_rue2, enterprise_ville, enterprise_cp, enterprise_pays, enterprise_tel, enterprise_rh_contact, enterprise_lieu_groupe, enterprise_lieu_rue1, enterprise_lieu_rue2, enterprise_lieu_ville, enterprise_lieu_cp, enterprise_lieu_pays, enterprise_lieu_tel', 'length', 'max'=>45),
			array('enterprise_rh_prenom, enterprise_rh_nom', 'length', 'max'=>30),
			array('debut_de_stage, fin_de_stage, mission', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, debut_de_stage, fin_de_stage, duree_de_stage, mission, enterprise_nom, enterprise_groupe, enterprise_rue1, enterprise_rue2, enterprise_ville, enterprise_cp, enterprise_pays, enterprise_tel, enterprise_rh_prenom, enterprise_rh_nom, enterprise_rh_contact, enterprise_lieu_groupe, enterprise_lieu_rue1, enterprise_lieu_rue2, enterprise_lieu_ville, enterprise_lieu_cp, enterprise_lieu_pays, enterprise_lieu_tel, rapportEvaluation_id, professeur_id, tuteurEvaluation_id, enterprise_id, soutenanceEvaluation_id, etudiant_id, stageContext_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'etudiant' => array(self::BELONGS_TO, 'Etudiant', 'etudiant_id'),
			'stageContext' => array(self::BELONGS_TO, 'StageContext', 'stageContext_id'),
			'enterprise' => array(self::BELONGS_TO, 'Enterprise', 'enterprise_id'),
			'professeur' => array(self::BELONGS_TO, 'Professeur', 'professeur_id'),
			'rapportEvaluation' => array(self::BELONGS_TO, 'RapportEvaluation', 'rapportEvaluation_id'),
			'soutenanceEvaluation' => array(self::BELONGS_TO, 'SoutenanceEvaluation', 'soutenanceEvaluation_id'),
			'tuteurEvaluation' => array(self::BELONGS_TO, 'TuteurEvaluation', 'tuteurEvaluation_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'debut_de_stage' => 'Debut De Stage',
			'fin_de_stage' => 'Fin De Stage',
			'duree_de_stage' => 'Duree De Stage',
			'mission' => 'Mission',
			'enterprise_nom' => 'Enterprise Nom',
			'enterprise_groupe' => 'Enterprise Groupe',
			'enterprise_rue1' => 'Enterprise Rue1',
			'enterprise_rue2' => 'Enterprise Rue2',
			'enterprise_ville' => 'Enterprise Ville',
			'enterprise_cp' => 'Enterprise Cp',
			'enterprise_pays' => 'Enterprise Pays',
			'enterprise_tel' => 'Enterprise Tel',
			'enterprise_rh_prenom' => 'Enterprise Rh Prenom',
			'enterprise_rh_nom' => 'Enterprise Rh Nom',
			'enterprise_rh_contact' => 'Enterprise Rh Contact',
			'enterprise_lieu_groupe' => 'Enterprise Lieu Groupe',
			'enterprise_lieu_rue1' => 'Enterprise Lieu Rue1',
			'enterprise_lieu_rue2' => 'Enterprise Lieu Rue2',
			'enterprise_lieu_ville' => 'Enterprise Lieu Ville',
			'enterprise_lieu_cp' => 'Enterprise Lieu Cp',
			'enterprise_lieu_pays' => 'Enterprise Lieu Pays',
			'enterprise_lieu_tel' => 'Enterprise Lieu Tel',
			'rapportEvaluation_id' => 'Rapport Evaluation',
			'professeur_id' => 'Professeur',
			'tuteurEvaluation_id' => 'Tuteur Evaluation',
			'enterprise_id' => 'Enterprise',
			'soutenanceEvaluation_id' => 'Soutenance Evaluation',
			'etudiant_id' => 'Etudiant',
			'stageContext_id' => 'Stage Context',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('debut_de_stage',$this->debut_de_stage,true);
		$criteria->compare('fin_de_stage',$this->fin_de_stage,true);
		$criteria->compare('duree_de_stage',$this->duree_de_stage);
		$criteria->compare('mission',$this->mission,true);
		$criteria->compare('enterprise_nom',$this->enterprise_nom,true);
		$criteria->compare('enterprise_groupe',$this->enterprise_groupe,true);
		$criteria->compare('enterprise_rue1',$this->enterprise_rue1,true);
		$criteria->compare('enterprise_rue2',$this->enterprise_rue2,true);
		$criteria->compare('enterprise_ville',$this->enterprise_ville,true);
		$criteria->compare('enterprise_cp',$this->enterprise_cp,true);
		$criteria->compare('enterprise_pays',$this->enterprise_pays,true);
		$criteria->compare('enterprise_tel',$this->enterprise_tel,true);
		$criteria->compare('enterprise_rh_prenom',$this->enterprise_rh_prenom,true);
		$criteria->compare('enterprise_rh_nom',$this->enterprise_rh_nom,true);
		$criteria->compare('enterprise_rh_contact',$this->enterprise_rh_contact,true);
		$criteria->compare('enterprise_lieu_groupe',$this->enterprise_lieu_groupe,true);
		$criteria->compare('enterprise_lieu_rue1',$this->enterprise_lieu_rue1,true);
		$criteria->compare('enterprise_lieu_rue2',$this->enterprise_lieu_rue2,true);
		$criteria->compare('enterprise_lieu_ville',$this->enterprise_lieu_ville,true);
		$criteria->compare('enterprise_lieu_cp',$this->enterprise_lieu_cp,true);
		$criteria->compare('enterprise_lieu_pays',$this->enterprise_lieu_pays,true);
		$criteria->compare('enterprise_lieu_tel',$this->enterprise_lieu_tel,true);
		$criteria->compare('rapportEvaluation_id',$this->rapportEvaluation_id);
		$criteria->compare('professeur_id',$this->professeur_id);
		$criteria->compare('tuteurEvaluation_id',$this->tuteurEvaluation_id);
		$criteria->compare('enterprise_id',$this->enterprise_id);
		$criteria->compare('soutenanceEvaluation_id',$this->soutenanceEvaluation_id);
		$criteria->compare('etudiant_id',$this->etudiant_id);
		$criteria->compare('stageContext_id',$this->stageContext_id);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}